import $ from 'jquery';
global.$ = global.jQuery = $;
import { showMsg } from "./../../js/base/utils";
import "./../../js/layui/css/layui.css";
require("./../../js/layui/layui");
(function ($) {
    layui.use(function () {
        var laydate = layui.laydate;
        var upload = layui.upload;
        laydate.render({
            elem: '#birthday'
        });

        upload.render({
            elem: '#change-avatar' //绑定元素
            , url: upyunurl //上传接口
            , accept: 'images' //允许上传的文件类型
            , size: 2048
            , done: function (responseText) {
                //上传完毕回调
                if (typeof responseText == "string") var responseText = $.parseJSON(responseText);
                if (responseText.code) {
                    showMsg(200, "上传成功!");
                    var newavatar = responseText.data[0];
                    $("#fileImg").attr("src", newavatar);
                    $("#avatar").val(newavatar);

                } else {
                    showMsg(responseText.code, responseText.message);
                }

            }
            , error: function () {
                showMsg(400, "上传失败!");
            }
        });
    });
})(jQuery);
